<?php
$imgPath = MEDIA_FOLDER . DS . "gallery" . DS . $data->picture;
?>
<li>

    <?php if (!file_exists($imgPath)) : ?>
        <div style="width: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH ?>px; height: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_HEIGHT ?>px;">
	    <?php
	    $imgPath = MEDIA_URL . DS . "gallery" . DS . LGConstant::FRONTEND_GALLERY_NO_PHOTO;
	    echo CHtml::image($imgPath, CHtml::encode($data->name), array(
		'style' => 'max-width:'.LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH.'px; max-height:'.LGConstant::FRONTEND_GALLERY_IMAGE_HEIGHT.'px'
	    ));
	    ?>
        </div>
        <div style="width: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH ?>px; height: 38px;overflow: hidden;vertical-align: middle;">
	    <?php echo $data->name ?>
        </div>
        <?php else :?>
        <div style="width: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH ?>px; height: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_HEIGHT ?>px;">
	    <?php
	    $imgUrl = url('gallery/thumbnails', array('f' => $imgPath,
		'w' => LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH,
		'h' => LGConstant::FRONTEND_GALLERY_IMAGE_HEIGHT,
	    ));

	    $img = CHtml::image($imgUrl, CHtml::encode($data->name)
	    );
	    echo CHtml::link($img, GALLERY_URL . '/' . $data->picture, array('class' => 'grouped_image',
		'rel' => 'slide[photos]', 'id' => 'photo-' . $data->id,
	    ));
	    ?>
        </div>
        <div style="width: <?php echo LGConstant::FRONTEND_GALLERY_IMAGE_WIDTH ?>px; height: 38px;overflow: hidden;vertical-align: middle;">
    	<a href="javascript:void(0);" onclick="$('#photo-<?php echo $data->id ?>')[0].click(); return false;"><?php echo $data->name ?></a>
        </div>
    <?php endif; ?>
</li>


